package com.prp.gwt.client.admin;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.prp.gwt.client.widgets.TopPanel;
import com.prp.gwt.client.widgets.admin.AdminView;

public class Admin implements EntryPoint{

	private static HTML loading = new HTML("正在载入...");
	
	public void onModuleLoad() {
		AdminListener.getInstance().verify();
		RootPanel.get().add(loading);
	}

	public static void init(){
		RootPanel.get().remove(loading);
		RootPanel.get("header").add(TopPanel.getInstance());
		RootPanel.get("content").add(AdminView.getInstance());
		
		History.addValueChangeHandler(new AdminHistoryHandler());
		if(History.getToken().equals(""))
			History.newItem(AdminHistoryHandler.ADMINLIST);
		else
			History.fireCurrentHistoryState();
		TopPanel.getInstance().setListener(AdminListener.getInstance());
		
		AdminListener.getInstance().updateUser();
	}
	
}
